     //查看订单备注
   function initSeeOrderInfo(){
	   $('.SeeProductBack').live('click', function () {
		var myrow = jQuery('#StatOrderList').jqGrid('getRowData',$(this).attr("rowId"));
												
		var Product_ID= myrow.Order_Products;
		//alert($("#Grop").attr("Grop"));
        seeProductBack(Product_ID,$("#User_ID").val(),$("#UP_ID").val(),$("#startTime").val(),$("#endTime").val(),$("#Grop").attr("Grop"),myrow.Product_Type);
			
 			 }
		);
	   }
  
  //初始化订单一级表格
   function initOrderJqgrid(){
		$( "button").button();
		initFind_Orderdatepicker();
		initFind_Autocomplete();
		initfindOrder();
		initSeeOrderInfo();
     $("#StatOrderList").jqGrid({
   	url:'../orderStatus/StatProductSaleNum.jsp',
	datatype: "xml",//'用户支付金额'
   	colNames:['产品ID','产品名称','客户','产品类型', '销售总数量','销售总金额','查看退货率'],
   	colModel:[
		{name:'Order_Products', width:100, sortable:false},
   		{name:'Product_Name',index:'Order_Total_Price', width:75},
		//{name:'Payment_Price',index:'Payment_Price', width:75},
   		{name:'User_ID',index:'Order_AddTime', width:100},
		{name:'Product_Type', width:100,sortable:false},
   		{name:'SaleNum', width:100, align:"left",sortable:false},
		{name:'SaleMoney', width:100,sortable:false },
   		{name:'ProductBack', width:100,sortable:false ,formatter:Fmatter_ProductBack},
   	],
	//scroll: true,
   	rowNum:15,
   	autowidth: true,
	height:400,
   	rowList:[10,20,30],
	prmNames:{page:'page',rows:'rows',order: 'sord', search:'_search', nd:'nd', npage:null},
	postData:{page:'page',rows:'rows', sort: 'sidx',order: 'sordsdf'},
   	pager: jQuery('#pager1'),
	loadCompele: $( "button").button(),
	loadError:   function(xhr,stu,e){alert(xhr.responseText);},
   	sortname: 'Order_AddTime',
    viewrecords: true,
    sortorder: "desc",
    caption:"XML Example",	
	forceFit : true, 
	cellEdit: true,
	cellsubmit: 'clientArray',
	afterEditCell: function (id,name,val,iRow,iCol){
		
	},
	afterSaveCell : function(rowid,name,val,iRow,iCol) {
		
	},
	
	onSelectRow: function(id){    
      
   },   
	gridComplete: function() {
    	$( "button").button();
    }, 
	//此事件在点击表格特定单元格时发生。rowid 为行ID；iCol 为列索引；cellcontent 为单元格中内容；e 点击事件对象
	onCellSelect:function(rowid,iCol,cellcontent,e){

		},
	editurl:"../userHandle/editUser.jsp",        
}).navGrid('#pager1',{edit:false,add:false,del:false,search: false }).navButtonAdd('#pager1',{   
   caption:"添加",    
   buttonicon:"ui-icon-add",    
   onClickButton: function(){    
    $('#AddOrder-form').dialog('open').children('form')[0].reset();  
   },    

   position:"last"  
});	
//jQuery("#list1").jqGrid('inlineNav',"#pager1");
	   }
	   
	   function Fmatter_ProductBack(cellvalue, options, rowObject){
		
		return "<button class='SeeProductBack' rowId='"+options.rowId+"'>查看退货率</button>"
		}
  
	   //初始化搜索订单添加时间
function initFind_Orderdatepicker(){
			var dates = $( "#startTime, #endTime" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "startTime" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	}
	   
//初始化搜索送货员下拉菜单
function initFind_Autocomplete(){
		$( "#Order_Products" ).autocomplete({
			minLength: 0,
			selectedIndex:0,
			 source: function (request, response) {            
			 request.page = "1";  
			 request.rows= "100"; 
			 request.Product_Name=encodeURIComponent(request.term);
	ajaxHandle("../productHandle/searchProduct.jsp","json",readJson(request),response) ; 
			 },
			select: function( event, ui ) {
				//log( ui.item ?
				//	"Selected: " + ui.item.value + " aka " + ui.item.id :
				//	"Nothing selected, input was " + this.value );
				//alert(ui.item.id);
				 //findDeliver(ui.item.value);
			}
		});
			$( "#User_ID" ).autocomplete({
			//source: "../userHandle/queryUser_Type.jsp",
			//source: "../userHandle/queryUser_Type.jsp",
			minLength: 0,
			selectedIndex:0,
			 source: function (request, response) {            
			 request.page = "1";  
			 request.rows= "100"; 
			 request.User_ID=encodeURIComponent(request.term);
			 request.User_Type='3';
	ajaxHandle("../userHandle/searchUser.jsp","json",readJson(request),response) ; 
			 },
			select: function( event, ui ) {
				//log( ui.item ?
				//	"Selected: " + ui.item.value + " aka " + ui.item.id :
				//	"Nothing selected, input was " + this.value );
				//alert(ui.item.id);
				// findDeliver(ui.item.value);
			}
		});
			$( "#UP_ID" ).autocomplete({
		
			minLength: 0,
			selectedIndex:0,
			 source: function (request, response) {            
			 request.page = "1";  
			 request.rows= "100"; 
			 request.User_ID=encodeURIComponent(request.term);
			 request.User_Type='2';
	ajaxHandle("../userHandle/searchUser.jsp","json",readJson(request),response) ; 
			 },
			select: function( event, ui ) {
				
			}
		});

					$( "#Grop" ).buttonset();
	
	}
	
function findStatOrder(Order_Products,User_ID,UP_ID,startTime,endTime,Grop){
		var Obj=eval("[]");
	  Obj.Order_Products=Order_Products;
	  Obj.User_ID=encodeURIComponent(User_ID);
	  Obj.UP_ID=encodeURIComponent(UP_ID);
	  Obj.startTime=startTime;
	  Obj.endTime=endTime;
	  Obj.Grop=Grop;
	  //ajaxHandle("../orderStatus/StatProductSaleNum.jsp","xml",readJson(Obj),backMsg) ; 
	  $("#StatOrderList").jqGrid('setGridParam',{ url: '../orderStatus/StatProductSaleNum.jsp',
postData:{Order_Products:Order_Products,User_ID:encodeURIComponent(User_ID),UP_ID:encodeURIComponent(UP_ID),startTime:startTime,endTime:endTime,Grop:Grop},
}).trigger('reloadGrid'); 
	}
	
	function seeProductBack(Order_Products,User_ID,UP_ID,startTime,endTime,Grop,Product_Type){
			var Obj=eval("[]");
	  Obj.Order_Products=Order_Products;
	  Obj.User_ID=encodeURIComponent(User_ID);
	  Obj.UP_ID=encodeURIComponent(UP_ID);
	  Obj.startTime=startTime;
	  Obj.endTime=endTime;
	  Obj.Grop=Grop;
	  Obj.Product_Type=Product_Type;
	  ajaxHandle("../orderStatus/ProductBack.jsp","xml",readJson(Obj),backMsg) ; 
		}
	 //添加用户提示
 function AddUserMsg(text){
	 
	 $( ".Add_User_Msg" ).text( text )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {			
				$( ".Add_User_Msg" ).removeClass( "ui-state-highlight", 1500 );
				 $( ".Add_User_Msg" ).text("");
			}, 500 );
	 }
 function Toalert(text){
	 alert(text);
	 }
	 
function backMsg(xmlResponse){
	var statuc=$(xmlResponse).find("statuc").text();	
	if(statuc=="true"){
		
		//AddUserMsg($(xmlResponse).find('msg').text());
		$("#list1").trigger("reloadGrid");
		alert($(xmlResponse).find('msg').text());
	
		}else{
		//AddUserMsg($(xmlResponse).find('msg').text());
		alert($(xmlResponse).find('msg').text());
		}
	} 
	
	function initfindOrder(){

			$("#radio1").click(
		    function(){
				//alert($("#search").serialize());
	findStatOrder($("#Order_Products").val(),$("#User_ID").val(),$("#UP_ID").val(),$("#startTime").val(),$("#endTime").val(),"Order_Products");	 
	$("#Grop").attr("Grop","Order_Products");
			}
		);	
			$("#radio2").click(
		    function(){
				//alert($("#search").serialize());
	findStatOrder($("#Order_Products").val(),$("#User_ID").val(),$("#UP_ID").val(),$("#startTime").val(),$("#endTime").val(),"Product_Type");	 $("#Grop").attr("Grop","Product_Type");
			}
		);	
	}
// JavaScript Document